dim doc
set doc = application.ActiveDocument

dim fileContent
fileContent = "Application.ExecuteCommand(""Display Colors Setup"")" & chr(13) & chr(10)	
fileContent = fileContent & "DisplayColorsSetupDlg.ColorGrid.Cell(""Paste Mask Bottom"", ""#"") = ""0""" & chr(13) & chr(10)
fileContent = fileContent & "DisplayColorsSetupDlg.ColorGrid.Cell(""Paste Mask Top"", ""#"") = ""0""" & chr(13) & chr(10)
'Top
if doc.ActiveLayer=1 then
fileContent = fileContent & "DisplayColorsSetupDlg.ColorGrid.Cell(""Paste Mask Top"", ""#"") = ""1""" & chr(13) & chr(10)
end if
'Bottom
if doc.ActiveLayer=doc.ElectricalLayerCount then
fileContent = fileContent & "DisplayColorsSetupDlg.ColorGrid.Cell(""Paste Mask Bottom"", ""#"") = ""1""" & chr(13) & chr(10)
end if
fileContent = fileContent & "DisplayColorsSetupDlg.Ok.Click()"

dim tmpfile
tmpfile = doc.path & "\tmp1.mcr"		
dim fso
Set fso = CreateObject("Scripting.FileSystemObject")	
Set file = fso.CreateTextFile(tmpfile, True)
file.Write fileContent
file.Close
Application.RunMacro(tmpfile)

